﻿using System;

namespace NKG_MVVM_UI
{
    class Program
    {
        static void Main(string[] args)
        {
            //创建UI对应的UI数据ViewModel
            Test01AViewModel test01AViewModel = VMManager.Instance.CreateVM<Test01AViewModel>();
            //显示一个UI(View)
            Test01View test01View = UIManager.Instance.OpenUI<Test01View>();
            //绑定V和VM
            test01View.BindingContext = test01AViewModel;

            //修改数据
            test01AViewModel.Text.Value = "Hello";
            test01AViewModel.Image.Value = 10000;
            //这个Model只有整体赋值才会触发委托
            //如果此处是test01AViewModel.Test01Model.Value.Text = XXX，就不会执行委托
            test01AViewModel.Test01Model.Value = new Test01Model {Text = "Hello", Image = 10000};

            //VMManager.Instance.GetVM<Test01AViewModel>().ChangeText("外部调用VM的函数更改Text");

            //打印目标的所有State历史
            StateManager.Instance.LogTargetState<Test01State>();

            //关闭UI，释放数据
            UIManager.Instance.CloseUI(test01View);
            VMManager.Instance.ReleaseVM(test01AViewModel);
        }
    }
}